//
//  StatusCellBottomView.swift
//  SinaWeibo
//
//  Created by apple on 15/11/16.
//  Copyright © 2015年 apple. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {

    //监听按钮的点击方法
    @objc func retweetBtnClick() {
        
        let vc = TempViewController()
        
        retweetBtn.NavController()?.pushViewController(vc, animated: false)
    }
   //MARK 初始化
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.96, alpha: 1.0)
        
        setUPUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //MARK 设置 UI
    
    private func setUPUI () {
        
        //添加子视图
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        
        let w:CGFloat = 0.5
        let scale = 0.4
        
        //设置约束
        retweetBtn.snp_makeConstraints { (make) -> Void in
            //上 左 高
            make.top.equalTo(self.snp_top)
            
            make.left.equalTo(self.snp_left)
            
            make.height.equalTo(self.snp_height)
            

        }
        
        let sepView1 = sepView()
        addSubview(sepView1)
        
        sepView1.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(retweetBtn.snp_right)
            
            make.height.equalTo(retweetBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            
            make.width.equalTo(w)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            
            // 上 左 高 等宽
            make.top.equalTo(self.snp_top)
            
            make.left.equalTo(retweetBtn.snp_right)
            
            make.height.equalTo(self.snp_height)
            
            make.width.equalTo(retweetBtn.snp_width)
        }
        
        let sepView2 = sepView()
        addSubview(sepView2)
        
        sepView2.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(commentBtn.snp_right)
            
            make.height.equalTo(commentBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            
            make.width.equalTo(w)
        }

        
        likeBtn.snp_makeConstraints { (make) -> Void in
            
            //上 左 高 右 等宽
            make.top.equalTo(self.snp_top)
            
            make.left.equalTo(commentBtn.snp_right)
            
            make.height.equalTo(self.snp_height)
            
            make.right.equalTo(self.snp_right)
            
            make.width.equalTo(commentBtn.snp_width)
        }
        
        //添加按钮的点击事件
        retweetBtn.addTarget(self, action: "retweetBtnClick", forControlEvents: .TouchUpInside)
        
    }
    
    //创建分割线
    private func sepView()->UIView {
        
        let v = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        
        return v
    }
    //MARK 懒加载控件
    private lazy var retweetBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    
     private lazy var commentBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    
     private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)
   
    
}
